// 类型推导
let uname; //未赋值是any
uname =1;
uname = 'jin'

//包装对象 
// 原始类型 对象类型
let name2 = 'jinyq'
//内部自动帮你包装成对象类型
console.log(new String(name2).toUpperCase())

let isOK: boolean = true; // 编译通过
// let isOK: boolean = Boolean(1) // 编译通过
// let isOK: boolean = new Boolean(1); // 编译失败   期望的 isOK 是一个原始数据类型

// 联合类型

let firstname: string | number;
firstname =3
firstname ='jinyq'

//类型断言
let name4 :string |number;
console.log((name4! as number).toFixed(2))
console.log((name4! as string).length)
console.log((name4! as boolean)) //报错
//双重断言
console.log(name4! as any as boolean)


// 字面量类型和类型字面量
const up:'Up' = 'Up'
const down:'Down'= 'Down'
const left: 'Left' ='Left'
const right:'Right' = 'Right'

type Direction = 'Up' |'Down' | 'Left' | 'Right'
function move(direction:Direction){

}
move('Down')

// 类型字面量
type Person = {
  name:string,
  age:number
};

//字符串字面量和联合类型
type T1 = '1' | '2' | '3'
type T2 = number | string | boolean
let t1:T1 = '1'
let t2:T2 = true